package com.iris.jvmtest.memory;

import java.util.ArrayList;
import java.util.List;

/**
 * @author : Iris.Xiao
 * @date : 2018/03/22 11:00
 * @description :
 */
public class OutMemoryTest {

    public void heapOut(){
        List<byte[]> list = new ArrayList<>();
        while (true){
            list.add(new byte[1024*1024]);
        }
    }
    public void gc(){
        int i=0;
        while (true){
            String str= "str"+i;
            i++;
            if(i%1000000==0){
                System.out.println(str);
            }
        }
    }

    public void permOut(){
        List<String> list = new ArrayList<>();
        int i=0;
        while (true){
            String str= "str"+i;
            str = str.intern();
            list.add(str);
            i++;
            if(i%100000==0){
                System.out.println(i);
            }
        }
    }
    public static void main(String[] args) {
        OutMemoryTest outMemoryTest = new OutMemoryTest();
        outMemoryTest.permOut();
//        outMemoryTest.gc();
    }
}
